<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />   
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
		<script type="text/javascript" src="../../scripts/grid/GroupSummary.js">
        </script>
		<script type="text/javascript" src="../../scripts/menu/EditableItem.js"></script>
		<script type="text/javascript" src="../../scripts/menu/RangeMenu.js"></script>
		<script type="text/javascript" src="../../scripts/grid/GridFilters.js"></script>
		<script type="text/javascript" src="../../scripts/grid/filter/Filter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/filter/DateFilter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
		<script type="text/javascript" src="../../scripts/imageViewer.js"></script>
        <script type="text/javascript">
        var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
        var uiMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.message');
        var messageName = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=com.hilaver.dzmis');
        var actionMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message.action');
        var store;
        var grid;

        var ctOperationXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtOperation');
        var ctClassNameXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtClassName');
        
        var ctOperation = getPrarmeterValue(window.location, 'ctOperation');
        if(ctOperation == null && operation == ''){
        	ctOperation = '03';
        }
        var setClose = function(id){
             Ext.Ajax.request({
             	url:'../../servlet/SysMboxServlet?action=20&id=' + id, 
                 success: function(o){
                     //if (o.responseText == 'success') {
                    	 store.load();
                     //}
                 },
                 failure: function(o){
                 },
                 params: {
                     foo: 'bar'
                 }
             });
		}

        Ext.onReady(function(){
        	store = new Ext.data.Store({
                url: '../../servlet/SysMboxServlet?action=4&ctOperation=' + ctOperation,
                
                reader: new Ext.data.XmlReader({
                    record: 'item',
                    id: 'id',
                    totalRecords: 'itemTotal'
                }, [ 
                'index', 'ctClassName', 'objId', 'parentClassName', 'parentObjId','ctOperation','modifier','modifyDate','isClosed', 'message', 'groupStr', 'id']),

                //groupField: 'groupStr',
                
                remoteSort: true
            });
            
        	store.setDefaultSort('modifyDate', 'desc');
        	var filters = new Ext.grid.GridFilters({
				  filters:[
					{type: 'list',  dataIndex: 'ctOperation', options: ctOperationXmlLoader.getCtArray() },
					{type: 'list',  dataIndex: 'ctClassName', options: ctClassNameXmlLoader.getCtArray() },
					{type: 'date',  dataIndex: 'modifyDate'},
					{type: 'string',  dataIndex: 'message'},
					{type: 'string',  dataIndex: 'modifier'}
			]});
        	//var summary = new Ext.grid.GroupSummary();
        	grid = new Ext.grid.GridPanel({
                title: actionMessage.get('message.action.dustbin'),
               	plugins: [filters],
                store: store,
        		stripeRows: true,
                height: 560,
                columns: [
                /*{
                    header: '',
                    dataIndex: 'groupStr'
                },*/
                {
                    header: message.get('message.list.id'),
                    width: 20,
                    dataIndex: 'index'
                }, 
                /*{
                    header: uiMessage.get('ui.message.isclosed'),
                    dataIndex: 'isClosed',
                    sortable: false,
                    width: 30,
                    renderer: function(value, metaData, record){
        	    		if(value == '01'){
            	    		return String.format('<img src="../../images/icons/tick.png" title="' + message.get('message.list.yes') + '" />');
        	    		}else{
        	    			return String.format('<img src="../../images/icons/cross.png" title="' + message.get('message.list.no') + '" />');
            	    	}
        	        }
                },*/
                {
                    header: uiMessage.get('ui.message.operation'),
                    dataIndex: 'ctOperation',
                    width: 30,
                    sortable: false,
                    renderer: function(value, metaData, record){
                    	if(value == '01'){
                    		return String.format('<img src="../../images/icons/add.png" title="' + message.get('message.action.add') + '" />');
                    	}else if(value == '02'){
                    		return String.format('<img src="../../images/icons/pencil.png" title="' + message.get('message.list.eidt') + '" />');	
                    	}else{
                    		return String.format('<img src="../../images/icons/delete.png" title="' + message.get('message.list.delete') + '" />');
                    	}
                	}
                }, {
                    header: uiMessage.get('ui.message.name'),
                    dataIndex: 'ctClassName',
                    sortable: false,
        	        renderer: function(value, metaData, record){
        	    		return messageName.get(value);
        	        }
                }, {
                    header: uiMessage.get('ui.message.message'),
                    dataIndex: 'message',
                    sortable: false
                }, {
                    header: uiMessage.get('ui.message.modifier'),
                    dataIndex: 'modifier',
                    sortable: false
                }, {
                    header: message.get('message.edit.date'),
                    dataIndex: 'modifyDate',
                    sortable: false
                }],

                /*                , {
                    header: message.get('message.edit.go'),
                    sortable: false,
                    width: 20,
                    renderer: function(value, metaData, record){
                    	var urlObj = getUrl(record.data.className);
        	    		return String.format('<a href="javascript:parent.addTab(\'{0}\', \'' + urlObj.url  + '\', \'{3}\');void(0);"><img src="../../images/icons/arrow_rotate_clockwise.png" title="{4}" /></a>', urlObj.menuId, record.data.objId, record.data.parentObjId, messageName.get(record.data.className),message.get('message.edit.go'),record.data.id);
        	        }
                }, {
                    header: uiMessage.get('ui.message.sendmsg'),
                    sortable: false,
                    width: 20,
                    renderer: function(value, metaData, record){
                		return String.format('<a href="sys_mbox_send.html?id={0}&startPage={2}"><img src="../../images/icons/email_go.png" title="{1}" /></a>',record.data.id,uiMessage.get('ui.message.sendmsg'), Math.floor((record.data.index - 1) / 20) + 1);
        	        }
                }
                , {
                    header: message.get('message.list.eidtitem'),
                    sortable: false,
                    width: 20,
                    renderer: function(value, metaData, record){
                		return String.format('<a href="javascript:void(0);"><img src="../../images/icons/comments.png" title="{1}" /></a>',record.data.id,message.get('message.list.eidtitem'));
        	        }
                }
                , {
                    header: uiMessage.get('ui.message.close'),
                    sortable: false,
                    dataIndex: 'isClosed',
                    width: 20,
                    renderer: function(value, metaData, record){
                    	var imgStr = '';
                    	if(value == '01'){
                    		imgStr = 'arrow_out.png';
                    	}else{
                    		imgStr = 'arrow_in.png';
                    	}
                		return String.format('<a href="javascript:setClose({0});void(0);"><img src="../../images/icons/' + imgStr + '" title="{1}" /></a>',record.data.id,uiMessage.get('ui.message.close'));
        	        }
                }],
                view: new Ext.grid.GroupingView({
                    forceFit: true,
        			hideGroupedColumn: true,
        			enableNoGroups:false,
                    groupTextTpl: '&nbsp;&nbsp;<b>' + uiMessage.get('ui.message.message') + ':</b>&nbsp;&nbsp;{[values.rs[0].data.message]}&nbsp;&nbsp;({[values.rs.length]}' + message.get('message.list.eidtitem') + ')'
                }),*/
                viewConfig: {
                    forceFit: true
                },
                loadMask: true,
                renderTo: 'sysMboxList',
                bbar: new Ext.PagingToolbar({
                    pageSize: 20,
                    store: store,
                    displayInfo: true
                })
            });

        	 var startPage = getPrarmeterValue(window.location, 'startPage');
             var start;
             if (startPage == null || startPage == '') {
                 start = 0;
             }
             else {
                 start = (startPage - 1) * 20;
             }
             store.load({
                 params: {
                     start: start,
                     limit: 20
                 }
             });

        });
        </script>
	</head>
	<body>
	 	<div id="sysMboxList">
        </div>
	</body>
</html>